<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>
    The Goods Page
</h1>

    <form th:action="@{/doFindObject}" method="get">
        <input type="text" name="name" >
        <input type="submit" value="查询">
        <input type="button" onclick="doLoadGoodsAddUI()" value="添加商品">
    </form>
    <table class="table">
        <thead>


        <tr>
            <th>id</th>
            <th>name</th>
            <th>remark</th>
            <th>createdTime</th>
            <th>delete</th>
            <th>update</th>


        </tr>
        </thead>
        <tbody>


        <tr th:each="g:${list}">
            <td th:text="${g.id}"></td>
            <td th:text="${g.name}"></td>
            <td th:text="${g.remark}"></td>
            <td th:text="${#dates.format(g.createdTime,'yy-MM-dd HH:mm')}"></td>
            <td><button th:onclick="doDeleteById([[${g.id}]])" type="button" class="btn btn-danger">delete</button></td>
            <td ><button th:onclick="doFindById([[${g.id}]])"type="button" class="btn btn-primary">update</button></td>

        </tr>
        </tbody>
    </table>
</div>
<script>
    var rooturl="http://localhost/"
    function doDeleteById(id){
        location.href=`${rooturl}/doDeleteById?id=${id}`
    }
    function  doLoadGoodsAddUI(){
        location.href=`${rooturl}/doGoodsAddUI`
    }
    function doFindById(id){
        location.href=`${rooturl}/doFindById/${id}`
    }
</script>

</body>
</html>